package org.swift.mashup.engine.deployment.mcr;

import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;
import org.swift.mashup.engine.deployment.MessageContextReader;

import java.util.HashMap;
import java.util.Map;

public class HttpMethodMessageContextReader implements MessageContextReader {
	public static final String HTTP_METHOD = "___httpMethod_";
	private static HttpMethodMessageContextReader instance = null;

	public static HttpMethodMessageContextReader getInstance() {
		if (instance == null) {
			instance = new HttpMethodMessageContextReader();
		}
		return instance;
	}

	private HttpMethodMessageContextReader() {
	}

	@Override
	public Map<String, Object> createParameterMap(MessageContext context) {
		Map<String,Object> paramMap = new HashMap<String,Object>();
		String method = (String)context.getProperty(HTTPConstants.HTTP_METHOD);
		if ( method != null ) {
			paramMap.put(HTTP_METHOD, method);
		}
		return paramMap;
	}
}
